package com.zcl.Thread.useThread;

/**
 * @Description:
 * @author: zcl
 * @date: 2022/3/8  18:28
 */
public class myThread extends Thread {

    public static void main(String[] args) {
        myThread myThread = new myThread();
        myThread.setName("myThread");
        myThread.start();

        try {
            for (int i = 0; i < 10; i++) {
                int time = (int) (Math.random()* 1000);
                Thread.sleep(time);
                System.out.println("main= "+ Thread.currentThread().getName());
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }


    @Override
    public void run(){
        try {
            for (int i = 0; i < 10; i++) {
                int time = (int) (Math.random()* 1000);
                Thread.sleep(time);
                System.out.println("run= "+ Thread.currentThread().getName());
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
